package com.base.controller;

import com.base.utils.Result;
import com.base.utils.ResultUtil;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * 用户登录Controller
 *
 * @author wnhuang
 * @Package com.base.controller
 * @date 2021-02-07 11:57
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/login")
    public Result login(@RequestBody String username) {
        System.out.println(username  + "登录...");
        Map<String, Object> map = new HashMap<>();
        map.put("token", UUID.randomUUID().toString());
        return ResultUtil.success(map);
    }

    @GetMapping("/info")
    public Result getInfo(String token) {
        System.out.println(token + "获取基本信息...");
        Map<String, Object> map = new HashMap<>();
        map.put("name","Super Admin");
        map.put("avatar","/api/upload/image/bc7b9dfa-243a-4f64-8087-49f2da006e4e.gif");
        map.put("roles","admin");
        return ResultUtil.success(map);
    }

    @PostMapping("/logout")
    public Result logout() {
        return ResultUtil.success();
    }

    @GetMapping("/attach")
    public Result attach() {
        return ResultUtil.success("success");
    }
}
